package sundun.sharding.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import sundun.sharding.aspect.ShardingJdbcDynamicDataSourceAspect;
import sundun.sharding.constant.ShardingConstant;
import sundun.sharding.properties.ShardingJdbcProperties;


/**
 * @author: zxl
 * @date: 2024/07/28 13:02
 **/
@Configuration
@EnableConfigurationProperties({ShardingJdbcProperties.class})
@ConditionalOnProperty(name = ShardingConstant.SPRING_SHARDING_SPHERE_ENABLED, havingValue = "true")
public class ShardingJdbcConfiguration {
    @Bean
    @ConditionalOnProperty(name = ShardingConstant.SPRING_SHARDING_SPHERE_ASPECT_ENABLED, havingValue = "true")
//    @ConditionalOnClass(name = "org.aspectj.lang.annotation.Aspect")
    public ShardingJdbcDynamicDataSourceAspect shardingJdbcDynamicDataSourceAspect(){
        return new ShardingJdbcDynamicDataSourceAspect();
    }
}
